package com.beetlsql.main;

import com.beetlsql.vo.ResultPO;
import org.beetl.sql.core.*;
import org.beetl.sql.core.db.DBStyle;
import org.beetl.sql.core.db.MySqlStyle;
import org.beetl.sql.ext.DebugInterceptor;


import java.util.HashMap;
import java.util.List;
import java.util.Map;


public class MainClass {

    public static void main(String[] args) {
        String driver = "com.mysql.cj.jdbc.Driver";
        String url = "jdbc:mysql://localhost:3306/erpcg_pd?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8";
        String username = "ogg4m";
        String password = "ogg4m123";
        ConnectionSource source = ConnectionSourceHelper.getSimple(driver, url, username, password);
        DBStyle mySqlStyle = new MySqlStyle();
        SQLLoader loader = new ClasspathLoader("/sql");
        UnderlinedNameConversion nc = new UnderlinedNameConversion();
        SQLManager sqlManager = new SQLManager(mySqlStyle,loader,source,nc,new Interceptor[]{new DebugInterceptor()});
        Map<String, Object> map = new HashMap<>(16);
        map.put("id", "134cf68455044d079048e187b7ace364");
        List<ResultPO> select = sqlManager.select("dbsql.queryById", ResultPO.class, map);

        ResultPO unique = sqlManager.unique(ResultPO.class, "134cf68455044d079048e187b7ace364");
        System.out.println(unique);
        System.out.println(select);

    }
}
